A readonly list of T
Object Model
Syntax
Type Parameters
Example
Library/Library.Test/TestReadOnlyList.cs
C# | Copy Code |
---|
ICollection read = new ReadOnlyList<int>((IEnumerable<int>)new int[] { 5, 10, 15 });
Assert.AreEqual(3, read.Count);
Assert.IsFalse(read.IsSynchronized);
Assert.IsTrue(Object.ReferenceEquals(read, read.SyncRoot));
long[] lary = new long[3];
read.CopyTo(lary, 0);
Assert.AreEqual(5L, lary[0]);
Assert.AreEqual(10L, lary[1]);
Assert.AreEqual(15L, lary[2]);
ICollection copy = (ICollection)((ICloneable)read).Clone();
Assert.AreEqual(3, copy.Count); |
VB.NET | Copy Code |
---|
Dim read As ICollection = New ReadOnlyList(Of Integer)(DirectCast(New Integer() {5, 10, 15}, IEnumerable(Of Integer)))
Assert.AreEqual(3, read.Count)
Assert.IsFalse(read.IsSynchronized)
Assert.IsTrue([Object].ReferenceEquals(read, read.SyncRoot))
Dim lary As Long() = New Long(3) {}
read.CopyTo(lary, 0)
Assert.AreEqual(5L, lary(0))
Assert.AreEqual(10L, lary(1))
Assert.AreEqual(15L, lary(2))
Dim copy As ICollection = DirectCast((DirectCast(read, ICloneable)).Clone(), ICollection)
Assert.AreEqual(3, copy.Count) |
Inheritance Hierarchy
Requirements
Target Platforms: Windows XP, Windows Server 2003, Windows Vista, Windows Server 2008, Windows 7
See Also